namespace SPDeploy.Library.Helpers
{
    using System.Collections;
    using Interfaces;

    public class DepthFirstTraversalStrategy : ITraversalStrategy
    {
        #region Fields: private

        private Stack _queue = new Stack();

        #endregion

        #region ITraversalStrategy Members

        public void Add(object o)
        {
            _queue.Push(o);
        }

        public T Next<T>()
            where T : class
        {
            return _queue.Pop() as T;
        }

        public bool HasItems
        {
            get { return _queue.Count > 0; }
        }

        public void Reset()
        {
            _queue = new Stack();
        }

        #endregion
    }
}